﻿//-----------------------------------------------------------------------
// <copyright file="DefaultGlobalCommandsProvider.cs" author="Artak Mkrtchyan">
//     Creative Commons - GNU General Public License (http://creativecommons.org/licenses/GPL/2.0/
// </copyright>
// <author>Artak Mkrtchyan</author>
// <email>mkArtak@gmail.com</email>
// <date>09/04/2013</date>
//-----------------------------------------------------------------------

using ConsoleHoster.Common.Model;
using ConsoleHoster.Common.Utilities;
using ConsoleHoster.Common.Utilities.Threading;
using ConsoleHoster.Model;
using ConsoleHoster.Model.Entities;
using ConsoleHoster.View.Popups;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleHoster.ViewModel
{
	internal class DefaultGlobalCommandsProvider : GenericSettingsProvider<GlobalCommandsView, IEnumerable<CommandData>, IEnumerable<CommandData>>, IGlobalCommandsProvider
	{
		public DefaultGlobalCommandsProvider(IDispatcher argDispatcher, ViewSettings argViewSettings, ILogger argLogger)
			: base(argDispatcher, argViewSettings, new ComponentLogger("DefaultGlobalCommandsProvider", argLogger))
		{
		}

		protected override GlobalCommandsView CreateView(IEnumerable<CommandData> argCurrentState)
		{
			return new GlobalCommandsView(argCurrentState, this.Dispatcher, this.Logger);
		}

		protected override IEnumerable<CommandData> RetrieveDataFromView()
		{
			return this.view.ViewModel.CommandListDetailsVM.Commands.Select(item => item.Model);
		}
	}
}
